import { RouteRecordRaw } from "vue-router";
import ExampleView from "@/views/ExampleView.vue";
import AboutPage from "@/views/AboutPage.vue";
import noAuthView from "@/views/noAuthView.vue";
import accessEnum from "@/access/accessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import ManageQuestionView from "@/views/question/ManageQuestionView.vue";
import ViewQuestionView from "@/views/question/ViewQuestionView.vue";
import QuestionsView from "@/views/question/QuestionsView.vue";
import QuestionSubmitView from "@/views/question/QuestionSubmitView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView
      }
    ],
    meta: {
      hideInMenu: true
    }
  },
  {
    path: "/",
    name: "题目广场",
    component: QuestionsView
  },
  {
    path: "/question_submit",
    name: "题目记录碑",
    component: QuestionSubmitView,
  },
  {
    path: "/add/question",
    name: "创建题目",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.USER
    }
  },
  {
    path: "/view/question/:id",
    name: "在线做题",
    component: ViewQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/update/question",
    name: "更新题目",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true
    }
  },
  {
    path: "/manage/question/",
    name: "管理题目",
    component: ManageQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN
    }
  },
  {
    path: "/about",
    name: "关于我的",
    component: AboutPage
  },
  {
    path: "/noAuth",
    name: "无权限",
    component: noAuthView,
    meta: {
      hideInMenu: true
    }
  },
  {
    path: "/test/edit",
    name: "管理员测试编辑器隐藏界面",
    component: ExampleView,
    meta: {
      hideInMenu: true,
      access: accessEnum.ADMIN
    }
  }
];
